package com.braveman.im.ui.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.TextView;

import com.braveman.im.R;
import com.braveman.im.bean.GroupOfDetailsBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView;

import java.util.List;


/**
 * 作者 昊昊.
 * 年份 2017/10/27.
 * 时间 10:20.
 * 项目名称 hhkj.
 */

/**
 * 群主页适配
 */
public class GroupOfDetailsAdapter extends BaseQuickAdapter<GroupOfDetailsBean.CoreMemberListBean, BaseViewHolder> {
    //    private GroupOfDetailsBean.CoreMemberListBean listBean;
    private TextView item_img_head;
    private Drawable drawable;
    private QMUIRadiusImageView qmuiRadiusImageView;

    public GroupOfDetailsAdapter(@LayoutRes int layoutResId, @Nullable List<GroupOfDetailsBean.CoreMemberListBean> data) {
        super(layoutResId, data);
    }

    // TODO: 2017/11/3 根据参数判断诚信值然后给TextView赋图片
    @Override
    protected void convert(BaseViewHolder helper, GroupOfDetailsBean.CoreMemberListBean item) {
        item_img_head = helper.getView(R.id.item_tx_title);
        item_img_head.setText(item.groupName);
        qmuiRadiusImageView = helper.getView(R.id.item_img_head);
        qmuiRadiusImageView.setCircle(false);
        Glide.with(mContext).load(item.groupIcon).into(qmuiRadiusImageView);
        switch (item.memberIntegrityIndex) {
            case 1:
                drawable = mContext.getResources().getDrawable(R.mipmap.star_level_1);
                break;
            case 2:
                drawable = mContext.getResources().getDrawable(R.mipmap.star_level_2);
                break;
            case 3:
                drawable = mContext.getResources().getDrawable(R.mipmap.star_level_3);
                break;
            case 4:
                drawable = mContext.getResources().getDrawable(R.mipmap.star_level_4);
                break;
            case 5:
                drawable = mContext.getResources().getDrawable(R.mipmap.star_level_5);
                break;
        }
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); //设置边界
        item_img_head.setCompoundDrawables(null, null, drawable, null);//画在右边
    }
}
